Skip to main content

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;
printf("Enter the Small letter here :");
scanf("%c",&s);
printf("the Capital letter is: %c", s-32);
}

5) WAP to interchange values of two numbers using third variable.

Ans:

#include<stdio.h>

void main()
{
float s,o,u;
printf("Enter the value S: ");
scanf("%f",&s);
printf("Enter the value O: ");
scanf("%f",&o);
u=s;
s=o;
o=u;

printf("Value of S: %.f\n",s);
printf("Value of O: %.f",o);
}


6) WAP to interchange values of two numbers without using third variable.

Ans:

#include<stdio.h>
void main()
{
float s,o;
printf("Enter the value S: ");
scanf("%f",&s);
printf("Enter the value O: ");
scanf("%f",&o);
s=s+o;
o=s-o;
s=s-o;
printf("Value of S=%.f\n",s);
printf("Value of O=%.f",o);

}

7) WAP to input two numbers and print their quotient and remainder.


Ans:


#include <stdio.h>
void main(){

int s, o, u, r;

printf("Enter The 1st nuumber: ");
scanf("%d", &s);

printf("Enter The 2nd number: ");
scanf("%d", &o);

u=s/o;

r=s%o;

printf("Quotient = %d\n",u);
printf("Remainder = %d",r);
}

8) WAP to enter base and height of a triangle and find its area.

Ans:

#include<stdio.h>
void main()
{
float s,o,area;
printf("Enter the base of the triangle : ");
scanf("%f",&s);
printf("Enter the height of the triangle : ");
scanf("%f",&o);
area=(s*o)/2;
printf("Area of this triangle is : %.2f",area);
}


9) WAP to calculate area of an equilateral triangle.

Ans:

#include<stdio.h>
void main()
{
float s,area;
printf("Enter value of a side : ");
scanf("%f",&s);
area=0.433*s*s;
printf("Area of the equilateral triangle is :%.2f",area);

}


10) WAP to enter three angles and check whether the triangle valid or not.

Ans:

#include<stdio.h>
void main()
{
float s,o,u;
printf("Enter the 1st angle of triangle : ");
scanf("%f",&s);
printf("Enter the 2nd angle of triangle : ");
scanf("%f",&o);
printf("Enter the 3rd angle of triangle : ");
scanf("%f",&u);

if(s+o+u==180){
printf("The triangle is valid");
}
else{
printf("This is not a triangle");
}

}


11) WAP to enter three side of triangle and check whether the triangle valid or not.

Ans:


#include<stdio.h>
void main()
{
float s,o,u;
printf("Enter 1st side of the triangle: ");
scanf("%f",&s);
printf("Enter 2nd side of the triangle: ");
scanf("%f",&o);
printf("Enter 3rd side of the triangle: ");
scanf("%f",&u);
if(s+o>u&&s+u>o&&u+o>s){
printf("This Triangle is valid");
}
else{
printf("This is not a Triangle");
}
}


12) WAP to enter three angle of triangle and check whether the right triangle or not.

Ans:

#include<stdio.h>
void main()
{
float s,o,u;
printf("enter the 1st angle of the triangle: ");
scanf("%f",&s);
printf("enter the 2nd angle of the triangle: ");
scanf("%f",&o);
printf("enter the 3rd angle of the triangle: ");
scanf("%f",&u);
if((s==90||o==90||u==90)&&(s+o+u==180)){
printf("This is a right Triangle");
}
else{
printf("This is not a right triangle or not a triangle");
}
}


13) WAP to enter three side of triangle and check whether the triangle is Isosceles or not.

Ans:

#include<stdio.h>
void main()
{
float s,o,u;
printf("Enter the 1st side of the triangle : ");
scanf("%f",&s);
printf("Enter the 2nd side of the triangle : ");
scanf("%f",&o);
printf("Enter the 3rd side of the triangle : ");
scanf("%f",&u);
if((s==o||s==u||o==u)&&(s+o>u&&s+u>o&&u+o>s)){
printf("This is a Isosceles triangle");
}
else{
printf("This is not a Isosceles triangle or not a triangle");
}

}


14) WAP to enter three side of triangle and check whether the triangle is Scalene or not.

Ans:

#include<stdio.h>
void main()
{
float s,o,u;
printf("Enter 1st side of the triangle : ");
scanf("%f",&s);
printf("Enter 2nd side of the triangle : ");
scanf("%f",&u);
printf("Enter 3rd side of the triangle : ");
scanf("%f",&o);
if((s!=o && s!=u && o!=u)&&(s+o>u&&s+u>o&&u+o>s)){
printf("This is a Scalene triangle ");
}
else{
printf("This is not a scalene or not a triangle");
}
}


15) WAP to enter three angles of triangle and check whether the triangle is Acute or not.

Ans:

#include<stdio.h>
void main()
{
float s,o,u;
printf("Enter the 1st angle of triangle: ");
scanf("%f",&s);
printf("Enter the 2nd angle of triangle: ");
scanf("%f",&o);
printf("Enter the 3rd angle of triangle: ");
scanf("%f",&u);
if(s<90 && o<90 && u<90 && s+o+u==180){
printf("This is a Acute Triangle ");
}
else{
printf("This is not a Acute Triangle or not a triangle ");
}
}


16) WAP to enter three angles of triangle and check whether the triangle is Obtuse or not.

Ans:

#include<stdio.h>
void main()
{
float s,o,u;
printf("Enter the 1st angle of triangle: ");
scanf("%f",&s);
printf("Enter the 2nd angle of triangle: ");
scanf("%f",&o);
printf("Enter the 3rd angle of triangle: ");
scanf("%f",&u);
if(s>90||o>90||u>90 && s+o+u==180){
printf("this is a Obtuse triangle");
}
else{
printf("this is not a Obtuse triangle or not a triangle");
}
}


17) WAP to enter marks of five subjects and calculate total, average and percentage.

Ans:

#include<stdio.h>
void main()
{
    int m,a,s,u,d,o,r,v;
    printf("Enter marks of five subjects here : ");
    scanf("%d %d %d %d %d",&m,&a,&s,&u,&d);
    o=m+a+s+u+d;
    r=o/5;
    v=o*100/500;
    printf("Total number : %d \n",o);
    printf("Average number : %d \n",r);
    printf("Percentage:%d",v);
}


18) WAP to input a number and check whether it is even or odd.

Ans:

#include<stdio.h>
void main()
{
int s;
printf("Enter the number here : ");
scanf("%d",&s);
if (s%2==0){
printf("This number is Even");
}
else{
printf("This number is odd");
}
}


19) WAP to input a number. If the number is even, print its square otherwise print its cube.

Ans:

#include<stdio.h>
void main()
{
int s;
printf("Enter the number here: ");
scanf("%d",&s);

if(s%2==0){
printf("This is Even and Square of the number is: %d",s*s);
}
else{
printf("This is odd and Cube of the number is: %d ",s*s*s);
}
}


20) WAP to input a number and check whether it is positive or negative.

Ans:

#include<stdio.h>
void main()
{
float s;
printf("Input the number here : ");
scanf("%f",&s);
if(s>0){
printf("this number is positive ");
}
else{
printf("this number is negative ");
}
}


21) WAP to input marks in three subjects of a student and calculate the division according to the
following conditions:
Percentage Division
>=60 First
50-59 Second
40-49 Third
<40 Fail

Ans:


#include<stdio.h>
void main()
{
    int s,o,u;
    printf("Enter the marks of 1st Subject: ");
    scanf("%d",&s);
    printf("Enter the marks of 2nd Subject: ");
    scanf("%d",&o);
    printf("Enter the marks of 2nd Subject: ");
    scanf("%d",&u);
    if(s>=60){
        printf("1st subject : First Division");
    }
    else if(s>=50&&s<=59){
        printf("1st subject : Second Division");
    }
    else if(s>=40&&s<=49){
        printf("1st subject : Third Division");
    }
    else if(s<40){
             printf("1st subject : Fail");
    }
if(o>=60){
        printf("\n 2nd subject : First Division");
    }
    else if(o>=50&&o<=59){
        printf("\n 2nd subject : Second Division");
    }
    else if(o>=40&&o<=49){
        printf("\n 2nd subject : Third Division");
    }
    else if(o<40){
             printf("\n 2nd subject : Fail");
    }
    if(u>=60){
        printf("\n 3rd subject : First Division");
    }
    else if(u>=50&&u<=59){
        printf("\n 3rd subject : Second Division");
    }
    else if(u>=40&&u<=49){
        printf("\n 3rd subject : Third Division");
    }
    else if(u<40){
             printf("\n 3rd subject : Fail");
    }

    if(s+o+u>=180){
        printf("\n Total : First Division");
    }
    else if(s+o+u>=150&&s+o+u<=177){
        printf("\n Total : Second Division");
    }
    else if(s+o+u>=120&&s+o+u<=147){
        printf("\n Total : Third Division");
    }
    else if(s+o+u<120){
             printf("\n Total : Fail");
    }
}


22) WAP to input a character and check that it’s a vowel or a consonant.

Ans:

#include<stdio.h>
void main()
{
char s;
printf("Enter the character here : ");
scanf("%c",&s);
if(s=='a'||s=='e'||s=='i'||s=='o'||s=='u'||s=='A'||s=='E'||s=='I'||s=='O'||s=='U'){
printf("This Character is a Vowel");
}
else{
printf("This Character is a Consonant");
}
}


23) WAP to input a character and check that it’s a small letter, capital letter, a digit or a special
symbol.

Ans:

#include<stdio.h>
void main()
{
    char s;
    printf("input character here :");
    scanf("%c",&s);
    if(s>=65 && s<=90)
    printf("capital letter");
    else if(s>=97 && s<=122)
        printf("small leter");
    else if(s>=48 && s<=57)
        printf("digit");
    else
        printf("special character");
}


24) WAP to find out the largest between three numbers.

Ans:

#include<stdio.h>
void main()
{
float s,o,u;
printf("Enter the 1st number here: ");
scanf("%f",&s);
printf("Enter the 2nd number here: ");
scanf("%f",&o);
printf("Enter the 3rd number here: ");
scanf("%f",&u);
if(s>o && s>u){
printf("the largest number is : %.2f ",s);
}
else if((o>s) && (o>u)){
printf("the largest number is : %.2f",o);
}
else{
printf("the largest number is : %.2f ",u);
}
}


25) WAP to find out the smallest between three numbers.



Ans:



#include<stdio.h>
void main()
{
float s,o,u;
printf("Enter the 1st number here: ");
scanf("%f",&s);
printf("Enter the 2nd number here: ");
scanf("%f",&o);
printf("Enter the 3rd number here: ");
scanf("%f",&u);
if(s<o && s<u){
printf("the smallest number is : %.2f ",s);
}
else if((o<s) && (o<u)){
printf("the smallest number is : %.2f",o);
}
else{
printf("the smallest number is : %.2f ",u);
}
}



Comments

Popular posts from this blog

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; }