Skip to main content

Lap Report of Rafi vai

1.Find the average of three numbers :


#include<stdio.h>
void main()
{
int a,b,c;
printf("input the 1st number here : ");
scanf("%d",&a);
printf("input the 2nd number here : ");
scanf("%d",&b);
printf("input the 3rd number here : ");
scanf("%d",&c);
printf("average of three numbers = %d",(a+b+c)/3);
}

2.Find the 2nd largest value from three input values :


#include<stdio.h>
void main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a==b&&b==c){
printf("They are Equal");
}
else if(a>b && a<c || a>c && a<b){
printf("2nd largest :%d ",a);
}
else if(b>a && b<c || b>c && b<a){
printf("2nd largest :%d ",b);
}
else{
printf("2nd largest : %d",c);
}
}

3.Convert Celsius temperature into Fahrenheit :



#include<stdio.h>
void main()
{
int a;
printf("input temperature in Celsius here: ");
scanf("%d",&a);
printf("Fahrenheit temperature = %d",((a*9)/5)+32);
}

4.Convert Fahrenheit temperature into Celsius :
#include<stdio.h>
void main()
{
int a;
printf("input temperature in Fahrenheit here: ");
scanf("%d",&a);
printf("Celsius temperature = %d",(a-32)*5/9);
}

5.Grading system :


#include<stdio.h>
void main()
{
int a;
printf("Enter the marks: ");
scanf("%d",&a);
if(a>=80){
printf("Grade: A+ ");
}
else if(a>=70&&a<=79){

printf("Grade: A ");
}
else if(a>=60&&a<=69){
printf("Grade: A-");
}
else if(a>=50&&a<=59){
printf("Grade: B");
}
else if(a>=40&&a<=49){
printf("Grade: C");
}
else if(a>=33&&a<=39){
printf("Grade: D");
}
else if(a<33){
printf(" Fail");
}
}

6.Input three numbers and sort them into ascending order :



#include<stdio.h>
void main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a>=b && a>=c && b>=c){
printf("ascending order : %d %d %d",c,b,a);
}
else if(a>=c && c>=b && a>=b){
printf("ascending order : %d %d %d",b,a,c);
}
else if(c>=a && c>=b && a>=b){
printf("ascending order : %d %d %d",b,a,c);
}
else if(c>=a && c>=b && b>=a){
printf("ascending order : %d %d %d",a,b,c);
}
else if(b>=a && b>=c && c>=a){
printf("ascending order : %d %d %d",a,c,b);
}
else{

printf("ascending order : %d %d %d",c,a,b);
}
}

7.Input three numbers and sort them into descending order :

#include<stdio.h>
void main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a>=b && a>=c && b>=c){
printf("Descending order : %d %d %d",a,b,c);
}
else if(a>=c && c>=b && a>=b){
printf("Descending order : %d %d %d",a,c,b);
}
else if(c>=a && c>=b && a>=b){
printf("Descending order : %d %d %d",c,a,b);
}
else if(c>=a && c>=b && b>=a){
printf("Descending order : %d %d %d",c,b,a);
}
else if(b>=a && b>=c && c>=a){
printf("Descending order : %d %d %d",b,c,a);
}
else{
printf("Descending order : %d %d %d",b,a,c);
}
}

8.Input a number which is less than 30 and express it as(sample input—5 output—Five)



#include<stdio.h>
int main()
{
int a;
printf("Enter number here ");

scanf("%d",&a);
if(a==0){
printf("Zero");
}
else if(a==1){
printf("one");
}
else if(a==2){
printf("two");
}
else if(a==3){
printf("Three");
}
else if(a==1){
printf("one");
}
else if(a==4){
printf("Four");
}
else if(a==5){
printf("Five");
}
else if(a==6){
printf("Six");
}
else if(a==7){
printf("Seven");
}
else if(a==8){
printf("Eight");
}
else if(a==9){
printf("Nine");
}
else if(a==10){
printf("Ten");
}
else if(a==11){
printf("eleven");
}
else if(a==12){
printf("twelve");
}
else if(a==13){
printf("thirteen");

}
else if(a==14){
printf("fourteen");
}
else if(a==15){
printf("fifteen");
}
else if(a==16){
printf("sixteen");
}
else if(a==17){
printf("seventeen");
}
else if(a==18){
printf("eighteen");
}
else if(a==19){
printf("nineteen");
}
else if(a==20){
printf("twenty");
}
else if(a==21){
printf("twenty-one");
}
else if(a==22){
printf("twenty-two");
}
else if(a==23){
printf("twenty-three");
}
else if(a==24){
printf("twenty-four");
}
else if(a==25){
printf("twenty-five");
}
else if(a==26){
printf("twenty-six");
}
else if(a==27){
printf("twenty-seven");
}
else if(a==28){
printf("twenty-eight");

}
else if(a==29){
printf("twenty-nine");
}
else if(a==30){
printf("thirty");
}
else{
printf("above thirty or negative");
}
}


9.Input a number n and find the summation of the numbers between 1to n



#include<stdio.h>
void main()
{
int n;
printf("Enter the Value of n : ");
scanf("%d",&n);
printf("Sum = %d ",n*(n+1)/2);
}

10.Input a number and check whether it is divisible by 3 and 5(both)or not :


#include<stdio.h>
void main()

{
int a;
printf("Enter the Number here : ");
scanf("%d",&a);
if(a%5==0 && a%3==0){
printf("it is divisible by 3 and 5");
}
else{
printf("it is not divisible by 3 and 5");
}
}

11.Input three number which denotes three gon of a trigon.Checkwhether it is possible to make a trigon with those three gons:



#include<stdio.h>
void main()
{
int a,b,c;
printf("Enter 1st side of the triangle: ");
scanf("%d",&a);
printf("Enter 2nd side of the triangle: ");
scanf("%d",&b);
printf("Enter 3rd side of the triangle: ");
scanf("%d",&c);
if(a+b>c&&a+c>b&&c+b>a){
printf("Triangle is Possible");
}
else{

printf("Triangle is not possible");
}
}

Comments

Popular posts from this blog

Shamim Sir Lap Report 2

1) WAP to accept any character from user and display its ASCII number on  screen. Ans: #include<stdio.h> void main() { char s; printf("Input the character here: "); scanf("%c",&s); printf("The ASCII of this Character: %d",s); } 2) WAP to input any ASCII number and display appropriate character on screen. Ans: #include<stdio.h> void main() { int s; printf("Input the ASCII number here: "); scanf("%d",&s); printf("The Character of ASCII:%c",s); } 3) WAP to input any Capital letter and display it with small letter. Ans: #include<stdio.h> void main() { char s; printf("Enter the Capital letter here :"); scanf("%c",&s); printf("the small letter is: %c", s+32); } 4) WAP to input any Small letter and display it with capital letter. Ans: #include<stdio.h> void main() { char s...

Let's Do It Again(long contest) || solve

A - Boys & Girls #include <stdio.h> int main() { int n, m, a, b, k = 0, l = 0; scanf("%d %d",&n,&m); while (n--) { scanf("%d %d",&a,&b); k=k+a; l=l+b; } printf("%d\n",(k+m-1)/m+(l+m-1)/m); return 0; } B - Conversion #include<stdio.h> int main() {     int n,s,o,u;     scanf("%d",&n);     s=n/10;     o=(n/100)*10+(n%10);     u=n%100;     if(u==0)     {             printf("%d\n",s);     }     else if(u>0&&u<10)     {     if(s<o)         printf("%d\n",s);         else         printf("%d\n",o);     }     else if(s==o&&u>s)         printf("%d\n",s);     else if(s==o&&u<s)   ...

URI Online Judge | 1001

Extremely Basic Read 2 variables, named  A  and  B  and make the sum of these two variables, assigning its result to the variable  X . Print  X  as shown below. Print endline after the result otherwise you will get “ Presentation Error ”. Input The input file will contain 2 integer numbers. Output Print the letter  X  (uppercase) with a blank space before and after the equal signal followed by the value of X, according to the following example. Obs.: don't forget the endline after all. Samples Input Samples Output 10 9 X = 19 -10 4 X = -6 ANS: #include<stdio.h> int main() { int A,B,X; scanf("%d %d",&A,&B); X=A+B; printf("X = %d\n",X); return 0; }