#Explanation:
The correct answer is 3rd becoz , as you all know that '//' are used for give a comment, comment means compiler will skip these part of the code, and will execute next statement of the code, but if I write a comment , which will terminate with '\' symbol then compiler will skip the next line of the code and will execute the third line of the code and that's known as "Line splicing".
Hope you understood!
Happy coding :)
The correct answer is 3rd becoz , as you all know that '//' are used for give a comment, comment means compiler will skip these part of the code, and will execute next statement of the code, but if I write a comment , which will terminate with '\' symbol then compiler will skip the next line of the code and will execute the third line of the code and that's known as "Line splicing".
Hope you understood!
Happy coding :)
Quiz. #2 what will be the output of the following c code?
#include <stdio.h>
int main(){ char ch = 'a'; char ch2 = 'b'; int add; add = ch + ch2; printf("res = %d", add); return 0; } Note: ASCII value: a=97, b=98
#include <stdio.h>
int main(){ char ch = 'a'; char ch2 = 'b'; int add; add = ch + ch2; printf("res = %d", add); return 0; } Note: ASCII value: a=97, b=98
Anonymous Quiz
6%
198
16%
c
58%
195
19%
Error!
Quiz. #3 what will be the output?
#include <stdio.h>
int main(){ int val1=50; int val2=50; int sum= val1+val2; printf("result = %c", sum); return 0; }
#include <stdio.h>
int main(){ int val1=50; int val2=50; int sum= val1+val2; printf("result = %c", sum); return 0; }
Anonymous Quiz
42%
100
25%
d
3%
50
31%
Error!
29. C program to find whether a character is a upper case character or lower case character or special symbol or a number(by using switch case instructions).
#include <stdio.h>
int main(){
char ch;
int val =0;
printf("enter a character: ");
scanf("%c",&ch);
if(ch>= 97 && ch<= 122)
val = 1;
else if(ch>=65 && ch<90)
val = 2;
else if(ch>=33 && ch<= 64 || ch>=91 && ch<=96)
val = 3;
else if(ch >= 48 && ch<=57)
val = 4;
else
val = 0;
switch(val){
case 1:
printf("%c is a lower case alphabet",ch);
break;
case 2:
printf("%c is a upper case alphabet",ch);
break;
case 3:
printf("%c is a special symbol",ch);
break;
case 4:
printf("%c is a numerical digit",ch);
default:
printf("Another character");
}
return 0;
}
#include <stdio.h>
int main(){
char ch;
int val =0;
printf("enter a character: ");
scanf("%c",&ch);
if(ch>= 97 && ch<= 122)
val = 1;
else if(ch>=65 && ch<90)
val = 2;
else if(ch>=33 && ch<= 64 || ch>=91 && ch<=96)
val = 3;
else if(ch >= 48 && ch<=57)
val = 4;
else
val = 0;
switch(val){
case 1:
printf("%c is a lower case alphabet",ch);
break;
case 2:
printf("%c is a upper case alphabet",ch);
break;
case 3:
printf("%c is a special symbol",ch);
break;
case 4:
printf("%c is a numerical digit",ch);
default:
printf("Another character");
}
return 0;
}
Bot for executing snippets of code; /help to get more information, /languages for list of languages. https://t.me/rextester_bot
C Coding
Bot for executing snippets of code; /help to get more information, /languages for list of languages. https://t.me/rextester_bot
This bot will help you to run your code on telegram
C Coding
This bot will help you to run your code on telegram
But it can not take any input from keyboard.
30. C program to find factorial of a given number using Recursion.
#include <stdio.h>
int factorial(int facto){
if (facto == 1 || facto == 0){
return 1;
}
else{
return facto * factorial (facto - 1);
}
}
int main(){
int facto;
printf("enter a number: ");
scanf("%d",&facto);
printf("factorial is %d", factorial (facto));
return 0;
}
#include <stdio.h>
int factorial(int facto){
if (facto == 1 || facto == 0){
return 1;
}
else{
return facto * factorial (facto - 1);
}
}
int main(){
int facto;
printf("enter a number: ");
scanf("%d",&facto);
printf("factorial is %d", factorial (facto));
return 0;
}
answer would be 'false' causes:
#explanation |Quiz. #4|
as we all know that when we use signed variable of any data type, first compiler will convert
it into unsigned value, proccess to convert signed into unsigned is that:
signed char = -23
1)binary of 23 is (00010111)
2)1's complement of (00010111) this : (11101000)
3)for convert it into unsigned add 1 into (11101000): 11101001 this is the binary of 233
and unsigned value of -23 is 233,
Now!
unsigned int i=23;
signed char c=-23;
if(i>c)
printf("true");
else
printf("false");
::: here we are comparing (23>233) which is false, so final answer would be false.
#explanation |Quiz. #4|
as we all know that when we use signed variable of any data type, first compiler will convert
it into unsigned value, proccess to convert signed into unsigned is that:
signed char = -23
1)binary of 23 is (00010111)
2)1's complement of (00010111) this : (11101000)
3)for convert it into unsigned add 1 into (11101000): 11101001 this is the binary of 233
and unsigned value of -23 is 233,
Now!
unsigned int i=23;
signed char c=-23;
if(i>c)
printf("true");
else
printf("false");
::: here we are comparing (23>233) which is false, so final answer would be false.
33. C program to convert numbers from decimal to binary.
#include <stdio.h>
int main() {
printf("***DECIMAL TO BINARY***\n");
int num ,i=0;
int arr[10];
scanf("%d",&num);
printf ("you have entered %d\nand its binary is: ",num);
while(num>0){
arr[i] = num % 2;
num = num / 2;
i++;
}
for(int j= i-1;j>=0; j--){
printf ("%d ",arr[j]);
}
return 0;
}
#include <stdio.h>
int main() {
printf("***DECIMAL TO BINARY***\n");
int num ,i=0;
int arr[10];
scanf("%d",&num);
printf ("you have entered %d\nand its binary is: ",num);
while(num>0){
arr[i] = num % 2;
num = num / 2;
i++;
}
for(int j= i-1;j>=0; j--){
printf ("%d ",arr[j]);
}
return 0;
}
35. C program to convert lower case character into upper case character (without using string functions).
#include <stdio.h>
int main()
{
char lower;
int upper;
printf("enter a lower case character: ");
scanf("%c",&lower);
if(lower >=97 && lower<= 122){
upper = lower - 32;
printf("%c",upper);
}
return 0;
}
#include <stdio.h>
int main()
{
char lower;
int upper;
printf("enter a lower case character: ");
scanf("%c",&lower);
if(lower >=97 && lower<= 122){
upper = lower - 32;
printf("%c",upper);
}
return 0;
}
36. C program to convert upper case character into lower case character (without using string functions).
#include <stdio.h>
int main()
{
int lower;
char upper;
printf("enter a upper case character: ");
scanf("%c",&upper);
if(upper >=65 && upper<= 90){
lower = upper + 32;
printf("%c", lower);
}
return 0;
}
#include <stdio.h>
int main()
{
int lower;
char upper;
printf("enter a upper case character: ");
scanf("%c",&upper);
if(upper >=65 && upper<= 90){
lower = upper + 32;
printf("%c", lower);
}
return 0;
}
37. Define a structure called VTUstudents , it comprise the fields: VTU No, Name, Branch of Study and Gender. Use array of structures for storing such records randomly. Design and develop a C program for clustering the records based on branch of study and gender (passing arrays aa argument).
#include <stdio.h>
#include <string.h>
struct vtu{
char sName[15];
char sBranch[4];
char sGender[15];
int vtu;
};
//struct vtu st;
void student(char name[15], char br[3], char gen[15], int vtu, int n){
struct vtu st;
int i;
char gender[10], branch[4];
printf("The rcords of vtu are: \n");
for(i=0; i<n; i++){
printf("%d\n", vtu);
printf("%s\n", name);
printf("%s\n", br);
printf("%s\n", gen);
}
printf("enter the gender to be printed: ");
scanf("%s", gender);
for(i=0; i<n; i++){
if(strcmp(gen, gender) == 0){
printf("%d\n", vtu);
printf("%s\n", name);
printf("%s\n", br);
printf("%s\n", gen);
}
}
printf("enter the branch to be printd: \n");
scanf("%s", branch);
for(i=0; i<n; i++){
if(strcmp(br, branch) == 0){
printf("%d\n",vtu);
printf("%s\n", name);
printf("%s\n", br);
printf("%s\n", gen);
}
}
}
int main()
{
struct vtu st[10];
int i,n;
// char gender[10], branch[4];
printf("Enter the number of records: ");
scanf("%d", &n);
for(i =0; i<n; i++){
printf("Enter details of student for record %d\n", i+1);
printf("enter vtu number: ");
scanf("%d", &st[i].vtu);
printf("enter name: ");
scanf("%s", st[i].sName);
printf("enter branch: ");
scanf("%s", st[i].sBranch);
printf("enter gemder: ");
scanf("%s", st[i].sGender);
student( st[i].sName, st[i].sBranch, st[i].sGender, st[i].vtu, n);
}
return 0;
}
#include <stdio.h>
#include <string.h>
struct vtu{
char sName[15];
char sBranch[4];
char sGender[15];
int vtu;
};
//struct vtu st;
void student(char name[15], char br[3], char gen[15], int vtu, int n){
struct vtu st;
int i;
char gender[10], branch[4];
printf("The rcords of vtu are: \n");
for(i=0; i<n; i++){
printf("%d\n", vtu);
printf("%s\n", name);
printf("%s\n", br);
printf("%s\n", gen);
}
printf("enter the gender to be printed: ");
scanf("%s", gender);
for(i=0; i<n; i++){
if(strcmp(gen, gender) == 0){
printf("%d\n", vtu);
printf("%s\n", name);
printf("%s\n", br);
printf("%s\n", gen);
}
}
printf("enter the branch to be printd: \n");
scanf("%s", branch);
for(i=0; i<n; i++){
if(strcmp(br, branch) == 0){
printf("%d\n",vtu);
printf("%s\n", name);
printf("%s\n", br);
printf("%s\n", gen);
}
}
}
int main()
{
struct vtu st[10];
int i,n;
// char gender[10], branch[4];
printf("Enter the number of records: ");
scanf("%d", &n);
for(i =0; i<n; i++){
printf("Enter details of student for record %d\n", i+1);
printf("enter vtu number: ");
scanf("%d", &st[i].vtu);
printf("enter name: ");
scanf("%s", st[i].sName);
printf("enter branch: ");
scanf("%s", st[i].sBranch);
printf("enter gemder: ");
scanf("%s", st[i].sGender);
student( st[i].sName, st[i].sBranch, st[i].sGender, st[i].vtu, n);
}
return 0;
}
👍1