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.
Display Salesman No and Salesman Name of East Zone.
Display Salesman No and Salesman Name of East Zone.
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.
Display the maximum and minimum Sales Amount.
Display the maximum and minimum Sales Amount.
Flashcards
C Program
C Program
A set of instructions written in C language to perform specific tasks.
Dynamic Memory Allocation
Dynamic Memory Allocation
Allocating memory at runtime using functions like malloc and free in C.
The malloc function
The malloc function
A standard library function in C used to allocate a specified number of bytes of memory.
Array in C
Array in C
Signup and view all the flashcards
Extracting Digits from String
Extracting Digits from String
Signup and view all the flashcards
MySQL INSERT Command
MySQL INSERT Command
Signup and view all the flashcards
Salesman Table Structure
Salesman Table Structure
Signup and view all the flashcards
Data Types in C
Data Types in C
Signup and view all the flashcards
SQL SELECT Statement
SQL SELECT Statement
Signup and view all the flashcards
Display records in SQL
Display records in SQL
Signup and view all the flashcards
Sales Amount Range Query
Sales Amount Range Query
Signup and view all the flashcards
MySQL MAX and MIN Functions
MySQL MAX and MIN Functions
Signup and view all the flashcards
SQL WHERE Clause
SQL WHERE Clause
Signup and view all the flashcards
Strings in C
Strings in C
Signup and view all the flashcards
Structuring MySQL Tables
Structuring MySQL Tables
Signup and view all the flashcards
Loop in C Programming
Loop in C Programming
Signup and view all the flashcards
ASCII Values
ASCII Values
Signup and view all the flashcards
Dynamic Array
Dynamic Array
Signup and view all the flashcards
Joining in SQL
Joining in SQL
Signup and view all the flashcards
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.