A character array that was taken from received raw SMS format was {'+','C','M','T',' ','2','0','2','0','-','2','9','-','1','2'}. Create a program that will extract the date and store it in a character array with the following format {'M','M','/','D','D','/','Y','Y','Y','Y'}. Use a function aside from main function that returns a value. See attached table in the instructions for additional requirement. Use "for loop" using C language.
#include<stdio.h>
#include<stdlib.h>
/*date function returns a char array of date format*/
char * date(char * sms,int n){
/*creating a char array of size 10*/
char * date=(char*)malloc(10*sizeof(char));
/*i stores index position of sms*/
int i=0;
/*index to store year in date array*/
int yr=0;
/*index to store year in date array*/
int mon=0;
/*index to store day in date array*/
int day=0;
/*while loop for iterating through each index*/
while(i<15){
/*if char is a number or - */
if((sms[i]>='0'&&sms[i]<='9')||sms[i]=='-'){
/*if i is less than 9*/
if(i<9){
/*store the year from sms in appropriate position in date*/
date[6+yr]=sms[i];
yr++;
}
/* if i is 9*/
else if(i==9){
/* insert / at index 5 in date*/
date[5]='/';
}
/*if i >=10 and i< =11*/
else if(i>=10 && i<=11){
/*insert day from sms into date array*/
date[3+day]=sms[i];
day++;
}
/* if i is 12 */
else if(i==12){
/* insert / at index 2 in date*/
date[2]='/';
}
else{
/*insert month from sms into date array*/
date[mon]=sms[i];
mon++;
}
}
i++;
}
return date;
};
int main(){
/*Sms array*/
char sms[15]={'+','C','M','T',' ','2','0','2','0','-','2','9','-','1','2'};
/*invoking date function and storing the date array in date 1*/
char * date1=date(sms,15);
/* Printing date */
printf("%s",date1);
}
A character array that was taken from received raw SMS format was {'+','C','M','T',' ','2','0','2','0','-','2','9','-','1','2'}. Create a program that will extract the date and store it in a character array with the following format {'M','M','/','D','D',
C++ Program Int Main First Please Write one program that does the following: 1. 1. Ask the user for ten (10) grades, and store the data in an array. Compute the average of all the grades. Print the original ten grades and the average. a. Declare an integer array with the name of “grades” of size 10 in the main function. b. Create a function called “getGrades” that prompts the User for the grades and puts them in an integer array. i. The function will receive...
Create 4 arrays: a 1-D array to store the students’ id, 1-D array to store the students’ names, a parallel 2-D array to store the test scores, and a parallel 1-D array to store letter grades. Read data into the 3 arrays from the file data121.txt. If the file is not found, the program needs to terminate with this error, “Data file not found.” Calculate and store a letter grade into a 1-D array based on the total score, sum...
Class Average Create a program that dynamically creates an array whose size depends on the user's preference. Pass the array to a calculate_avg function that is responsible for computing the average GPA of the given array. Use pointer arithmetic throughout your program. calculate_avg Create a function called calculate_avg that calculates the average of a double array and returns that average. calculate_avg() will have two parameters: a double* referring to the array an int that contains the size of the given...
c++ help please!
Create a 2D character array in your main function and
use nested for loops to fill the array with the letter ‘e’ to
represent empty spaces.
Create a function to print the board on the screen using
a nested for loop. The function header is:
void printBoard (char board [][3])
Create a function that checks whether a particular space
has already been filled. If the space is filled it returns a
boolean value of true, otherwise false....
C programming 1) When setting a two-dimensional character array, how is the size (number of characters) in the second dimension set? Select an answer: The number of elements are equal to the average size of all the strings. To the length of the longest string; you don't need to add one because the first array element is zero. To the length of the longest string, plus one for the null character. The second dimension is equal to the number of...
please use c++ language 1. Request three different integers from the console. a) Write a swap function that swaps two integer values. b) Write a sort function which accepts three integers as input then sorts them from largest to smallest using the swap function. c) Output the integers before and after sorting. Example 1 Output (input in bold italics) Enter three different integers: 3 2 4 3 2 4 4 3 2 Example 2 Output (input in bold italics) Enter...
Question 1 In the following incomplete C program: #include stdlib.h> #include <stdio.h> int main () { int i, n, max; int array[100]; ... } return 0; } an array of random int values is populated with n random values. Write only the code to find the location of the maximum value in the array. Question 2 Follow these instructions in your Linux account: 1. Create a file called data.txt in the root folder in your account. 2. Create a new...
C++ please Possible algorithms – (1) use and modify the algorithm from program 2 if possible; (2) use unique value array; (3) use flag array (flags used to avoid counting a number more than 1 time); (4) compute frequency distribution (use unique and count arrays); (5) use count array to store the frequency of a number. No global variable are permitted in this assignment. Do not change the code provided only write the missing code. Write the missing C++ statements...
C++ Programming - Design Process I need to create a flow chart based on the program I have created. I am very inexperienced with creating this design and your help will be much appreciated. My program takes a string of random letters and puts them them order. Our teacher gave us specific functions to use. Here is the code: //list of all the header files #include <iomanip> #include <iostream> #include <algorithm> #include <string> using namespace std; //Here are the Function...
C++ program Correctly complete the following assignment. Follow all directions. The main purpose is to show super and sub class relationships with an array of super media pointers to sub class objects and dynamic binding. The < operator will be overloaded in the super class so all subclasses can use it. The selection sort method will be in the main .cpp file because it will sort the array created in main. The final .cpp file, the three .h header class...