0% found this document useful (0 votes)
17 views2 pages

C Programming Practice Questions

ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

Uploaded by

tanushree
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

C Programming Practice Questions

ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

Uploaded by

tanushree
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Debug the error(s) if any in the given code and find the output

Q1.
#include<stdio.h>
void fn(int *ptr) {
printf("%d\n", *ptr);
}

int main() {
int *ptr;
fn(ptr);
return 0;
}
Q2.
#include<stdio.h>
int add(int a, int b) {
int result= a + b;
}

int main() {
int result;
add(5, 10);
printf("%d\n", result);
return 0;
}
Q3.
#include<stdio.h>
int main()
{
int arr[5] = {1, 2, 3, 4, 5};
int *ptr = arr;
printf("%d\n", *(ptr + 4));
printf("%d\n", *(ptr + 6));
}
Q4.
#include<stdio.h>
void add_one(int *x)
{
*x = *x + 1;
}
void add_two(int x) {
x = x + 2;
}
int main()
{
int a = 5;
add_one(&a);
printf("value of a after add_one call %d\n", a);
add_two(a);
printf("value of a after add_two call %d\n", a);
return 0;
}
Q5.
#include<stdio.h>
int main()
{
int a = 10;
int *ptr1 = &a;
int *ptr2 = &a;
*ptr1+=1;
*ptr2+=1;
printf("%d\n", a);
}
Q6.
#include<stdio.h>
#include <stdio.h>
struct Student {
int roll_no;
char name;
float marks;
};

int main() {
Student student;
Student *ptr;
// Point the pointer to the address of the structure variable
____________

// Assign 101 to roll_no, name to Radha, marks to 89.5 via pointer


_______________

// Print the structure fields using the pointer

_______________
return 0;
}
Q7.
Write a program for the following requirements using structures.
Create a student structure with dno(int), subjectcodes(array of int) registered already.
When the student registers for a subject, your program will have to permit the registration only
when the student has not already registered for that subject. The student can register for
maximum of two subjects at a time.

You might also like