0% found this document useful (0 votes)
79 views

Computer Programming Report

This document contains a collection of 12 computer programs written in the C programming language by Deshan A/L Ravi of Class 2 Amanah at KOLEJ YAYASAN SAAD. The programs include: 1. A BMI calculator 2. A program to calculate age 3. A program to count grades from an array of marks 4. A program to calculate IQ 5. A basic calculator 6. A program to check for palindromes 7. A program to print a multiplication table 8. A program to calculate factorials 9. A looping program 10. A multiplication program 11. A program to check if a number is odd or even

Uploaded by

deshan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views

Computer Programming Report

This document contains a collection of 12 computer programs written in the C programming language by Deshan A/L Ravi of Class 2 Amanah at KOLEJ YAYASAN SAAD. The programs include: 1. A BMI calculator 2. A program to calculate age 3. A program to count grades from an array of marks 4. A program to calculate IQ 5. A basic calculator 6. A program to check for palindromes 7. A program to print a multiplication table 8. A program to calculate factorials 9. A looping program 10. A multiplication program 11. A program to check if a number is odd or even

Uploaded by

deshan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

KOLEJ YAYASAN SAAD

COMPUTER PROGRAMMING

NAME : DESHAN A/L RAVI


CLASS : 2 AMANAH
I/C NO. : 990621045195
CONTENT

No. Title Page


1 Programme to calculate BMI 3
2 Programme to calculate our age 4
3 Programme to count the grade. 5

4 Programme to calculate your IQ 6


5 Calculator programme 7
6 Programme to determine palindrom (2) 8
7 Programme to print multiplication table 9
8 Programme to calculate factorial value 10
9 Programme to do looping 11
10 Programme to do multiplication 12
11 Programme to check odd or even 13
12 Programme to check mark of a student 14
Question

Calculate your BMI

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

Calculate the age

Input

//Finding Age Programme

#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

Programme to count the grade.

Input

//program to count the grades of 8 marks


#include <stdio.h>
int main()
{int marks[8]={73,84,80,89,92,94,85,92};
int a=0,b=0,c=0,d=0,f=0;
int i;
for(i=0;i<8;i++)
{if(marks [i]>=80)a=a+1;
else if(marks [i]>=70)b=b+1;
else if(marks [i]>=60)c=c+1;
else if(marks [i]>=40)d=d+1;
else f=f+1;
}
printf("You got %d many A grades",a);
printf("You got %d many B grades",b);
printf("You got %d many C grades",c);
printf("You got %d many D grades",d);
printf("You got %d many F grades",f);

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

Aim: to determine palindrom

Program listing (Input)

/*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

- To learn how to perform looping (repetition) using for statement in C language.

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;

printf("The factorial value of %d=%d\n",n,f);

system("pause");

Output
Question

Looping

Input

//program to print thank you teacher n times

#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

//program to check odd or even

#include<stdio.h>

int main()

int n; char opt;

while(opt=='y'||opt=='Y');

printf("Enter your number :");

scanf("%d",&n);

if(n%2==0) printf("even");

else printf("ODD\n");

printf("Do you wish want to continue? <Y/N>:\n");

scanf("%c",&opt);

system("pause");

Output
Date: 6/2/2013

Aim: to check the mark of a student in a particular subject

Program listing

//To check whether the student is pass in the particular subject

# include<stdio.h>

int main()

{ int mark;

printf(" Hei silly boy faster enter your 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");

You might also like