Computer Programming Report
Computer Programming Report
COMPUTER PROGRAMMING
Input
#include<stdio.h>
int main()
{
float bmi,w,h;
printf("please enter your weight");
scanf("%f",&w);
printf("please enter your height");
scanf("%f",&h);
bmi=w/(h*h);
if (bmi< 18.5) printf("You are under weight. Try to feed your
stomach.");
else if (bmi<25) printf("You are normal. Keep it up.");
else printf("You are overweight. Try to do more exercise.");
system("pause");
}
Output
Question
Input
#include<stdio.h>
#include<conio.h>
int main()
{
int bd , bm , by , cd , cm , cy , ad , am , ay ;
printf("Enter the current date<date,month,year seperately> :");
scanf("%d%d%d",&bd ,&bm ,&by);
printf("enter your date of birth<date,month,years seperately>:");
scanf("%d%d%d", &bd &bm &by);
if(cd<bd)
{cm=cm-1;cd=cd+30;}
if(cm<bm)
{cy=cy-1;cm=cm+12;}
ad=cd-bd;am=cm=bm;ay=cy-by;
printf("\n\t Your age is %d years %d months %d days \n ", ay,am,ad);
printf("\n\t You are so young and
beatiful!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
system("pause");
}
Output
Date: 3 July 2013
Title
Input
system("pause");
}
Output
Question
Calculate your iq
Input
#include<stdio.h>
int main()
{
float r, area,c;
printf("Please enter your height * weight * your favourite number");
scanf("%f",&r);
area=3.14*r*r;
c*=2*3.14*r;
printf("The intelligence of you is=%0.2f",area);
system("pause");
}
Output
Question
Calculater programme
Input
/*calculator programme*/
#include<stdio.h>
void main()
{
float a,b,c; char op;
printf("Enter the which of the maths symbol you want:
");scanf("%c",&op);
printf(" enter the two numbers:");scanf("%f%f",&a,&b);
switch (op)
{
case'+':c=a+b;break;
case'-':c=a-b;break;
case'*':c=a*b;break;
case'/':c=a/b;break;
default:printf("the symbol must be +,-,* or /");
c=0;break;
}
printf("\nThe result=%.2f",c);
system("pause");
}
Output
` Date: 6/2/2013
/*Palindrom Programme*/
#include<stdio.h>
#include<string.h>
void main()
{
char s[25];char rs[25];
int i,n,j=0;
printf("Hey , faster enter anyting");
scanf("%s",s);
//findimg the string length
n=strlen(s);
// reversing the string
for(i=n-1;i>=0;i--)
{
rs[j]=s[i];
j++;
}
rs[j]='\0';
//string comparison using strcmp
if (strcmp(s,rs)==0) printf(" IT IS a PalinDrom!!!!!!!!!");
else printf("it is not palindrom -_- ");
system("pause");
}
Output
Aim
-to learn how to perform looping (repeating) using for statement in C language.
Question
-Write a computer program using C language to print the multiplication table for the number
requsted by the user.
PROGRAM
# include<stdio.h>
int main()
int i,n;
printf(" Hei, silly boy faster enter the multipplication table you want.");
scanf("%d",&n);
for(i=1;i<=100;i++)
printf("\n%d*%d=%d",i,n,i*n);
system("pause");
OUTPUT
Aim
Question
- Write a computer program using C language to calculate the factorial value of a given
number. Example : 5!=1*2*3*4*5=120
Program
#include<stdio.h>
int main()
int i,n,f=1;
printf(" Hei smart boy faster enter your factorial value :");
scanf("%d",&n);
for (i=1;i<=n;i++)
f=f*i;
system("pause");
Output
Question
Looping
Input
#include<stdio.h>
int main()
{
int count;int n;
printf("How many times you want me to tell thank you sir?");
scanf("%d",&n);
for(count=1;count<=n;count=count+1)
{
printf("THANK YOU TEACHER! FOR TEACHING ME. YOU ARE THE BEST!\n");
}
system("pause");
}
Output
Questions
To do multiplication
Input
# include<stdio.h>
int main()
{
int i,n;
printf(" Hei, silly boy faster enter the multiplication table you
want.");
scanf("%d",&n);
for(i=1;i<=100;i++)
{
printf("\n%d*%d=%d",i,n,i*n);
}
system("pause");
}
Output
Question
To print the given number as odd an event repeatedly until user wants to quit using do while loop
Input
#include<stdio.h>
int main()
while(opt=='y'||opt=='Y');
scanf("%d",&n);
if(n%2==0) printf("even");
else printf("ODD\n");
scanf("%c",&opt);
system("pause");
Output
Date: 6/2/2013
Program listing
# include<stdio.h>
int main()
{ int mark;
scanf("%d",& mark);
if(mark>=50) printf(" Congratulations. You have prove to me that you're not a silly boy");
else printf(" HAHAHA stupid boy. Better drink MILO. Play more Learn more");
system("pause");