Thursday, September 29, 2011

WAP to perform this :: 123->one two three

#include<stdio.h>
#include<conio.h>
int rev(int);
void main()
{
    int num,a,rem,sum;
    clrscr();
    printf("enter a number");
    scanf("%d",&num);
    a=rev(num);
    while(a>0)
    {
        rem=a%10;
        a=a/10;
switch(rem)
{
case 1:
printf("one\n");
break;

case 2:
printf("two\n");
break;

case 3:
printf("three");
break;

case 4:
printf("four");
break;

case 5:
printf("five");
break;

case 6:
printf("six");
break;

case 7:
printf("seven");
break;

case 8:
printf("eight");
break;

case 9:
printf("nine");
break;

case 0:
printf("zero");
break;

default:
printf("wrong input");
}
}
getch();

}
int rev(int num)

WAP to convert 10 base number into base 2, base 8, base 16

#include<stdio.h>
#include<conio.h>
con(int,int);
void main()
{
int num,ch;
clrscr();
printf("enter a  decimal number\n");
scanf("%d",&num);
printf("1-binary\n");
printf("2-hexadecimal\n");
printf("3-ocatal\n");
printf("\n");
printf("enter your choice\n");
scanf("%d",&ch);

WAP to show use of ceil and floor function

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
float x=1.66;
float y=1.75;
clrscr();
printf("%f\n%f",ceil(y),floor(x));
getch();
}

o/p
x=2.000000
y=1.000000


WAP to find absolute value of a number

#include<stdio.h>
#include<conio.h>
void main()
{
    int num;
    clrscr();
    printf("enter the number");
    scanf("%d",&num);
    if(num<0)
    {
        num=-num;
        printf("the absolute of no. is %d",num);
    }
    else
    {
        printf("the absolute of no. is %d",num);
    }
        getch();
}

Wap to calculate Library Fine

#include<stdio.h>
#include<conio.h>
void main()
{
int day;
float fine;
clrscr();
printf("enter the  no. of dates the member is lateto return the book :");
scanf("%d",&day);
if (day>0 && day<=5)

Tuesday, September 27, 2011

Some objective question in c



Subject: Computers                                                                    MM: 25
Code     : PCS151                                                                     Time: 20 Minutes
--------------------------------------------------------------------------------------------------------
Note: 1.  All questions carry equal marks. No negative marking.
           2. Do not write or mark anything on question paper.
--------------------------------------------------------------------------------------------------------

Q1-C is written by:
A. Dennis Ritchie                                                        B. strostrup                   
C. Daniela                                                                      D. None

Q2.A pixel is
A. A computer program that draws picture                        B. A picture stored in secondary memory
C. The smallest resolvable part of picture                   D. None of these

Q3.Which of the following is not a keyword:
A. long                                                                             B. int                     
 C. float                                                                            D. main

Q4.Which of the following is not a format specifier:
A. %d              B. %i                           C. %e               D. %#x                        E. none

Wednesday, September 21, 2011

WAP to find the size of all data types


 
// program to find the size of all data types                                 

#include<stdio.h>                                                            
#include<conio.h>                                                            
void main()                                                                   
{                                                                            
 clrscr();                                                                   
 printf("\n The number of bytes int takes is %d", sizeof(int));              
 printf("\n The number of bytes float takes is %d", sizeof(float));          
 printf("\n The number of bytes double take is%d",sizeof(double));        
 printf("\n The size of bytes char takes is %d",sizeof(char));               
 printf("\n The size of bytes long takes is %d",sizeof(long));               
 printf("\n----------------");                                               
 getch();                                                                     
}                                                                            

Output:
The number of bytes int takes is 2
The number of bytes float takes is 4
The number of bytes double takes is 8
The number of bytes char takes is 1
The number of bytes long takes is 4
____________________________