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

Write A C Program To Evaluate R X y + (Y+3) (x-2)

The document contains 16 C programs with examples of basic programming concepts: 1. A program to evaluate a mathematical expression entered by the user. 2. A program to calculate the area and perimeter of a circle given its radius. 3. A program to determine a student's grade based on their total marks. 4. Programs using while loops to display numbers in various ranges. 5. Programs using for loops to display numbers based on certain conditions. 6. Programs demonstrating use of functions to perform arithmetic, logical, and other operations on numbers. 7. A program to check if a number is prime.

Uploaded by

Ali Bhagwan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Write A C Program To Evaluate R X y + (Y+3) (x-2)

The document contains 16 C programs with examples of basic programming concepts: 1. A program to evaluate a mathematical expression entered by the user. 2. A program to calculate the area and perimeter of a circle given its radius. 3. A program to determine a student's grade based on their total marks. 4. Programs using while loops to display numbers in various ranges. 5. Programs using for loops to display numbers based on certain conditions. 6. Programs demonstrating use of functions to perform arithmetic, logical, and other operations on numbers. 7. A program to check if a number is prime.

Uploaded by

Ali Bhagwan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

1.

WRITE A C PROGRAM TO EVALUATE R=x3y2+(y+3)(x-2)


#include<stdio.h>
#include<math.h>
int x, y, R;
main()
{
printf("Enter any two integers");
printf("\n x=");
scanf("%d", &x);
printf("\n y=");
scanf("%d", &y);
R= pow(x,3)*pow(y,2)+(y+3)*(x-2);
printf("\n R=%d", R);
}
2. WRITE A C PROGRAM TO FIND THE AREA AND PERIMETER OF A CIRCLE GIVEN ITS RADIUS
#include<stdio.h>
#include<math.h>
float r, A, P;
float pi= 3.1415;
main()
{
printf("Enter the radius of the circle");
printf("\n radius=");
scanf("%f", &r);
A = pi*r*r;
printf("\n Area of the Circle=%f",A);
P= pi*2*r;
printf("\n Perimeter of the Circle=%f",P);
}
3. A C PROGRAM TO PRINT THE GRADE OF A STUDENT BY ACCEPTING HIS TOTAL MARKS
#include<stdio.h>
float total;
float percent;
main()
{
printf("Enter the total marks scored by student ot of 600\n");
scanf("%f", &total);
percent=(total/600)*100;
if(percent>=75.0)
{
printf("\n Grade of student = DISTINCTION");
}
else
{
if(percent>=60.0)
{
printf("\n Grade of student = FIRST CLASS");
}
else
{
if(percent>=50.0)
{
printf("\n Grade of student = Second CLASS");
}
else
{
if(percent>=40.0)
{
printf("\n Grade of student = Pass CLASS");
}
else
{
printf("\nGrade of student = Fail");
}
}
}
}
4. WRITE A C PROGRAM TO DISPLAY NUMBERS FROM 100 TO 200 USING WHILE STATEMENT
#include<stdio.h>
int count;
main()
{
count=100;
while (count<=100)
{
printf("%d\t" ,count);
count++;
}
}
5. WRITE A C PROGRAM TO DISPLAY ONLY ODD NUMBERS FROM 1 TO 100 USING WHILE STATEMENT
#include<stdio.h>
int count;
main()
{
count=1;
while (count<=100)
{
if(count%2!=0)
{
printf("%d\t",count);
}
count++;
}
}
6. WRITE A C PROGRAM TO DISPLAY ONLY EVEN NUMBERS FROM 1 TO 100 USING WHILE STATEMENT
#include<stdio.h>
int count;
main()
{
count=1;
while (count<=100)
{
if(count%2==0)
{
printf("%d\t", count);
}
count++;
}
}
7. WRITE A C PROGRAM TO DISPLAY ONLY THOSE NUMBERS DIVISIBLE BY 3 FROM 1 TO 100 USING DO-
WHILE STATEMENT
#include<stdio.h>
int count;
main()
{
count=1;
do
{
if(count%3==0)
{
printf("%d\t", count);
}
count++;
}while (count<=100);
}
8. WRITE A C PROGRAM TO DISPLAY FIBONACCI NUMBERS BETWEEN 1 AND 100 USING DO-WHILE
STATEMENT
#include<stdio.h>
int i, j, k;
main()
{
i=1;
j=2;
printf("%d\t %d",i, j);
do
{
k= i+j;
printf("\t %d", k);
i=j;
j=k;
}while (k<=100);
}
9. WRITE A C PROGRAM TO DISPLAY only ODD NUMBERS FROM 1 TO 100 USING FOR STATEMENT
#include<stdio.h>
int count;
main()
{
for(count=1;count<=100;count++)
{
if(count%2!=0)
{
printf("%d\t",count);
}
}
}
10. WRITE A C PROGRAM TO DISPLAY ONLY EVEN NUMBERS FROM 1 TO 100 USING FOR STATEMENT
#include<stdio.h>
int count;
main()
{
for(count=1;count<=100;count++)
{
if(count%2==0)
{
printf("%d\t", count);
}
}
}
11. WRITE A C PROGRAM TO DISPLAY MULTIPLICATION TABLE OF A NUMBER USING FOR STATEMENT
#include<stdio.h>
int N, count;
main()
{
printf("Enter any integer");
scanf("%d", &N);
for(count=1;count<=10;count++)
{
printf("\n\t %d x %d = %d", N, count, N*count);
}
}
12. WRITE A C PROGRAM TO ACCEPT TWO NUMBERS AND PERFORM ARITHMETIC OPERATIONS ON THEM
USING A FUNCTION
#include<stdio.h>
#include<math.h>
int A,B;
void Arithmetic();
main()
{
printf("Enter any two integers");
printf("\nA=");
scanf("%d",&A);
printf("\nB=");
scanf("%d",&B);
Arithmetic();
}
void Arithmetic()
{
int R;
R= A+B;
printf("\n Result of Addition = \t %d",R);
R= A-B;
printf("\n Result of Subtraction = \t %d",R);
R= A*B;
printf("\n Result of Multiplication = \t %d",R);
R= A/B;
printf("\n Quotient of Division = \t %d",R);
R= A%B;
printf("\n Reminder of Division = \t %d",R);
R= pow(A,B);
printf("\n A raised to the power B = \t %d",R);
R= pow(B,A);
printf("\n B raised to the power A = \t %d",R);
}
13. WRITE A C PROGRAM TO ACCEPT TWO NUMBERS AND PERFORM BITWISE LOGICAL OPERATIONS ON
THEM USING A FUNCTION
#include<stdio.h>
int A,B;
void Logical();
main()
{
printf("Enter any two integers");
printf("\nA=");
scanf("%d",&A);
printf("\nB=");
scanf("%d",&B);
Logical();
}
void Logical()
{
int R;
R= A&B;
printf("\n Result of AND operation = \t %d",R);
R= ῀R;
printf("\n Result of NAND operation = \t %d",R);
R= A|B;
printf("\n Result of OR operation = \t %d",R);
R=῀ R;
printf("\n Result of NOR operation = \t %d",R);
R= A^B;
printf("\n Result of EX-OR operation = \t %d",R);

}
/* please note῀ symbol key is available on top left hand corner and it means complement*/

14. WRITE A C PROGRAM TO ACCEPT TWO NUMBERS AND FIND THE LARGEST OF TWO NUMBERS USING A
FUNCTION
#include<stdio.h>
int A,B;
void Large();
main()
{
printf("Enter any two integers");
printf("\nA=");
scanf("%d",&A);
printf("\nB=");
scanf("%d",&B);
Large();
}
void Large()
{
if (A==B)
printf("\nBoth are equal");
else
{
if(A>B)
printf("\n A= %d is the largest", A);
else
printf("\n B= %d is the largest", B);
}
}

15. WRITE A C PROGRAM TO ACCEPT TWO NUMBERS AND CHECK IF THEY ARE ODD/EVEN USING A
FUNCTION
#include<stdio.h>
int A,B;
void Odd_Even();
main()
{
printf("Enter any two integers");
printf("\nA=");
scanf("%d",&A);
printf("\nB=");
scanf("%d",&B);
Odd_Even();
}
void Odd_Even()
{
if(A%2==0)
printf("\n A=%d is an Even number", A);
else
printf("\n A=%d is an Odd number",A);
if(B%2==0)
printf("\n B=%d is an Even number", B);
else
printf("\n B=%d is an Odd number",B);
}
16. WRITE A C PROGRAM TO ACCEPT A NUMBER AND CHECK IF IT IS PRIME
#include<stdio.h>
int N,i;

main()
{
printf("Enter any integers");
printf("\nN=");
scanf("%d",&N);
switch(N)
{
case 1: {
printf("The number 1 is a Prime number");
break;
}
case 2: {
printf("The number 2 is a Prime number");
break;
}
default:
{
for(i=2;i<=N-1;i++)
{
if (N%i==0)
{
printf("\n N= %d is not a prime number",N);
break;
}
}
if (i==N)
printf("\n N= %d is a prime number", N);
}
}
}

You might also like