Skip to main content

Posts

Showing posts from April, 2020

Solve-write C program to find big element & it's position using array

C program to find big element & it's position using array Problem Description This program takes the 3 numbers and finds the biggest among all and show it's position. Problem Solution 1. Take the size of array. 2.  take the element. 3. initialize arr[0] into big like big=arr[0]. 4. for loop check the element with big in IF block . 5. print the big number and it's position. Program codes:- here the program of finding biggest of three number run this in your Linux, DEV C++,turbo c++   #include<stdio.h> main() { int n,i,pos,big,arr[20]; printf("\n enter the size of array:"); scanf("%d",&n); printf("\n enter the element of array:"); for(i=0;i<n;i++) { printf("\n arr[%d]=",i); scanf("%d",&arr[i]); } big=arr[0]; for(i=0;i<n;i++) { if(arr[i]>big) { big=arr[i]; pos=i; }     }     printf("\n big number is :%d",big);  

Solve-write C program to check given string is palindrome or not

C program to check given string is palindrome or not   program code  #include<stdio.h> #include<string.h> main() { char str[100]; int i=0,j; printf("\n enter any string:"); gets(str); j=strlen(str)-1; while(i<=j/2) { if(str[i]==str[j]) { i++; j--; } else break; } if(i>=j) printf("\n given string is palindrome:"); else printf("\n given string is not palindrome:"); } program output: - first output is to show the given string is palindrome second output is to show the given string is not palindrome

Solve-write C program to find the grade of marks of a student using switch case statement

C program to find the grade of marks of a student using switch case statement Problem Description This program take input as your number then show your grade. So first divide the mark by 10 so we can get a reminder and as you can see in the program we use case 4 to case 10. So if the remainder is between 4 to 10 our case perform the particular grade operation and display the result See the Step By Step Example for each case may be in this grade problem. Explanation Case 1:-  If the user is Over smart then there is a condition that if the mark given by the user is greater than 100 then our program display the Message "Don't Be Smart Enter your Marks Between Limit" or else perform the Else part. Enter the Mark:- 1000 Output:- Don't Be Smart Enter your Marks Between Limit. Case 2:-  If the user is entering the marks between the 0 to 100 and then particular grade portion will be executed and display the output in Console screen. Enter the Mark:- 95 Ou

Solve-write C program to find grade of student by using nested else-if statement

C program to find grade of student by using nested else-if statement Problem Description This program take input as your number then show your grade. Problem Solution 1. enter your marks as input. 2. then check your marks with 'If' block's condition. if it satisfied then show your grade as output. 3. if it not satisfied then it checks with all else-if block's condition repeatedly. 4. print the grade according to your given marks as input and exit. Program codes:-   #include<stdio.h> main() { int n; printf("\n enter the marks:"); scanf("%d",&n); if(n>89) printf("O"); else if(n>79) printf("E"); else if(n>69) printf("A"); else if(n>59) printf("B"); else if(n>49) printf("C"); else if(n>39) printf("D"); else printf("F"); } Program explanation:- 1. enter your marks. for example we take 70 .

Solve-write C program to find biggest number from three number by using nested if statement

          C program to find biggest number from three number                                                by using                                                                 nested if statement Problem Description This program takes the 3 numbers and finds the biggest among all. Problem Solution 1. Take the three numbers as input. 2. Check the first number if it greater than other two. 3. Repeat the step 2 for other two numbers. 4. Print the number which is greater among all and exit. Program codes:- here the program of finding biggest of three number run this in your Linux, DEV C++,turbo c++ #include<stdio.h> main() { int num1,num2,num3,big;          printf("enter the value for num1:");          scanf("%d",&num1);         printf("enter the value for num2:");         scanf("%d",&num2);        printf("enter the value for num3:");        scanf("%d",&num3); if(num1>num3

write aSwapping two values in C without using temp variable:-

Swapping  two values in C without using temporary variable :-   #include<stdio.h>    main()    {     int a,b;     printf("enter the value of a:");     scanf("%d",&a);     printf("enter the value of b:");     scanf("%d",&b);     a=a+b;     b=a-b;     a=a-b;     printf("a=%d",a);     printf("b=%d",b);    } for example we take value of a=3 and b=2. at first  "a=a+b" performed then the value of  "a=3+2;a=5" ,now the value of a is 5. after that  "b= a-b" performed then the value of  "b=5-2;b=3" ,now the value of b is 3. at last  "a=a-b"  performed then the value of  "a=5-3;a=2" ,now the value of a is 2 so after swapping  the value of a is  2   and value of b is  3 You can take input any value of a&b. If u write this program correctly then you see this output