BCA Programmer
194 subscribers
20 photos
8 videos
26 files
21 links
Download Telegram
//Program to check fail or pass using ternary operator

#include <stdio.h>
int main()
{
int marks;
printf("Enter marks (0-100): ");
scanf("%d", &marks);

(marks <= 30 )? printf("Fail\n") : printf("Pass\n");
return 0;
}
// marks < 33is C
// 33<=marks < 70 is B
// 70 <= marks <90 is A
// 90 <= marks <= 100 is A+


#include <stdio.h>
int main()
{
int marks;
printf("Enter marks (0-100): ");
scanf("%d", &marks);

if (marks<33 ){
printf("Grade C\n");
}
else if(marks>=33 && marks<70) {
printf("Grade B");
}
else if(marks >=70 && marks <90) {

printf("Grade A");
}
else {
printf("Grade A+\n");
printf("Topper");
}

return 0;
}
// to find Uppercase and Lowercase character

#include <stdio.h>
int main()
{
char ch;
printf("Enter character : ");
scanf("%c", &ch);
if (ch >='A' && ch <='Z' )
{
printf("Uppercase\n");
}
else if (ch >= 'a' && ch <='z' ) {
printf("Lowercase\n");
}
else {
printf("Not an English letter");
}
return 0;
}
// For loop statement

#include <stdio.h>
int main (){
//for(initialization;;condition;updation)
for(int i=1;i<=10;i++){
printf("Hello India\n");
}
return 0;
}
loop can be float or character
#include <stdio.h>
int main()
{
for(float i=1.0;i<=5.0;i++){
printf("%f\n", i);
}
for(char ch='a';ch<='z';ch++)
{
printf("%c", ch);
}
return 0;
}
send this code to your coder girlπŸ˜‚πŸ˜‚

#include <stdio.h>
int main()
{
for(int i=1; ;i++){

\\in this code we initialized value but we didn't update so it will be keep printing output continue

printf("I love you <3 ", i);
}
return 0;
}
while statement is little bit different from for statement.

#include <stdio.h>
int main()
{ int i=1;
while(i<=5){
printf("I love you <3 ", i);
i++;
}

return 0;
}
while loop

#include <stdio.h>
int main()
{ int n;
printf("Enter n : ");
scanf("%d", &n);
int i=1;
while (i<=n){
printf("%d\n", i,n);
i++;
}
return 0;
}
do-while loop

#include <stdio.h>
int main()
{
int i=1;

do
{
printf("%d\n", i);
i++;
} while (i<=5);


return 0;
}
Question for you
Print
the number from 0 to n, n is given by user.
Question 2 for you
Print
the number from n to 0, n is given by user.
BCA Programmer
Question for you Print the number from 0 to n, n is given by user.
#include <stdio.h>
int main(){
int n;
printf("Enter n : ");
scanf("%d", &n);
for(int i=0;i<=n;i++){
printf("%d\n", i,n);
}
return 0;
}
BCA Programmer
Question 2 for you Print the number from n to 0, n is given by user.
#include <stdio.h>
int main(){
int n;
printf("Enter n : ");
scanf("%d", &n);
for(int i=n;i>=0;i--){
printf("%d\n", i,n);
}
return 0;
}
C program to print the sum of FIrst n Natural Numbers.

#include <stdio.h>
int main() {
int n;
printf("enter number : ");
scanf("%d", &n);

int sum = 0;
for(int i=1; i<=n; i++){
sum = sum + i;
}
printf("sum is %d \n", sum);
return 0;
}
C program to print table of n.

#include <stdio.h>

int main() {
int n;

printf("Enter number : ");
scanf("%d", &n);

printf("Table of %d is : \n");

for(int i=1;i<=10;i++){
printf("%d\n", n*i);
}

return 0;
}
C program to take num as input from user until user enters an odd number.

#include <stdio.h>
int main(){
int n;
do{
printf("Enter number : ");
scanf("%d",&n);
printf("%d\n",n);
if(n%2 !=0){
break;
}
} while(1);

return 0;
}
C program to print all odd nums between 5 to 50.

#include <stdio.h>

int main() {

for(int i=5;i<=50;i++){
if (i%2 !=0){
printf("%d\n", i);

}
}
return 0;
}
πŸ‘1
"C" program that reads a character and prints out whether or not
it is a vowel or a consonant.


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

char ch;

printf("Enter letter : ");
scanf("%c", &ch);

if(ch =='a' ch =='e' ch =='i' ch =='o' ch =='u'
ch =='A' ch =='E' ch =='I' ch =='O'|| ch =='U'){
printf("%c is a Vowel\n", ch);
}

else {
printf("%c is a Consonent" ,ch);
}

return 0;
}
πŸ‘1