Podcast
Questions and Answers
Write a C program to extract the individual digits from a given string.
Write a C program to extract the individual digits from a given string.
#include <stdio.h>
#include <string.h>
int main() {
char str[100];
int i, len;
printf("Enter a string: ");
gets(str);
len = strlen(str);
printf("The digits in the string are: ");
for (i = 0; i < len; i++) {
if (str[i] >= '0' && str[i] <= '9') {
printf("%c ", str[i]);
}
}
return 0;
}
Write a C program to dynamically allocate memory for an array to store 10 integers and display the first 5 out of them.
Write a C program to dynamically allocate memory for an array to store 10 integers and display the first 5 out of them.
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr, i;
// Dynamically allocate memory for an array of 10 integers
ptr = (int *)malloc(10 * sizeof(int));
if (ptr == NULL) {
printf("Memory allocation failed!
");
return 1;
}
// Assign values to the array
printf("Enter 10 integers:\n");
for (i = 0; i < 10; i++) {
scanf("%d", &ptr[i]);
}
// Display the first 5 integers
printf("The first 5 integers are:\n");
for (i = 0; i < 5; i++) {
printf("%d ", ptr[i]);
}
// Free the dynamically allocated memory
free(ptr);
return 0;
}
Insert data into the table as follows:
Insert data into the table as follows:
INSERT INTO Sales (SalesmanNo, SalesmanName, DateOfJoining, SalesZone, SalesAmount)
VALUES
('S001', 'Ratul Saha', '2015-07-06', 'SOUTH', 8000000),
('S002', 'Amir Hamza', '2017-08-09', 'EAST', 3400000),
('S003', 'Pankaj Pathak', '2018-03-09', 'WEST', 2400000),
('S004', 'Abdus Salam', '2019-08-05', 'NORTH', 5000000),
('S005', 'Amrit Paul', '2013-07-09', 'SOUTH', 4700000),
('S006', 'Ramesh Sharma', '2012-05-12', 'EAST', 7000000);
Display Salesman No and Salesman Name of each record.
Display Salesman No and Salesman Name of each record.
Signup and view all the answers
Display Salesman No and Salesman Name of East Zone.
Display Salesman No and Salesman Name of East Zone.
Signup and view all the answers
Display the records having Sales Amount in the range 2,00,000 to 3,50,000.
Display the records having Sales Amount in the range 2,00,000 to 3,50,000.
Signup and view all the answers
Display the maximum and minimum Sales Amount.
Display the maximum and minimum Sales Amount.
Signup and view all the answers
Study Notes
C Programming
- Write a C program to extract individual digits from a given string
- Write a C program to dynamically allocate memory
- Store 10 integers
- Display first 5 integers
MySQL Queries
-
Insert Data:
- Insert data into a table, including:
- Salesman No
- Salesman Name
- Date of Joining
- SalesZone
- SalesAmount
- Example Data:
- S001, Ratul Saha, 2015-07-06, SOUTH, 8,00,000
- S002, Amir Hamja, 2017-08-09, EAST, 3,40,000
- ... and so on (see table)
- Insert data into a table, including:
-
Queries:
- Display Salesman No and Salesman Name for all records
- Display Salesman No and Salesman Name for East Zone
- Display records with Sales Amount between 2,00,000 and 3,50,000
- Maximum and Minimum Sales Amount
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
This quiz covers essential topics in C programming and MySQL queries. It includes tasks such as extracting digits from strings, dynamic memory allocation in C, and inserting and querying data in MySQL. Test your knowledge and skills in both programming and database management.